﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Mvc;

namespace DHQGHN.PM0.Models.Admin
{
    public class UserInGroupModel
    {
        public int UserInGroupId { get; set; }
        [Remote("CheckExistUserInGroup", "UserInGroup", ErrorMessage = "Người dùng đã gán cho nhóm", HttpMethod = "POST", AdditionalFields = "GroupId")]
        [Range(1, Int64.MaxValue, ErrorMessage = "Bạn chưa chọn người dùng")]
        [Display(Name = "Người dùng")]
        public int UserId { get; set; }
        [Range(1, Int64.MaxValue, ErrorMessage = "Bạn cần chọn nhóm")]
        [Display(Name = "Nhóm")]
        public int GroupId { get; set; }

        public int IsActive { get; set; }

        public int RecordCount { get; set; }

        public string Username { get; set; }
        public string Groupname { get; set; }
        public string UserCode { get; set; }
        public string Email { get; set; }
        public string Fullname { get; set; }

        public const string FIELD_RECORD_COUNT = "RecordCount";

        #region Field list from database
        public const string FIELD_ID = "MenuInRoleId";
        public const string FIELD_EMAIL = "Email";
        public const string FIELD_FULL_NAME = "Fullname";
        public const string FIELD_USER_CODE = "UserCode";
        public const string FIELD_USER_NAME = "Username";
        public const string FIELD_GROUP_NAME = "Groupname";
        //public const string FIELD_EMAIL = "Email";
        #endregion

        public UserInGroupModel()
        {
            // TODO: Complete member initialization
        }

        public UserInGroupModel(DAL.Models.Admin.UserInGroupModel model)
        {
            // TODO: Complete member initialization
            UserInGroupId = model.UserInGroupId;
            UserId = model.UserId;
            GroupId = model.GroupId;
            Groupname = model.Groupname;
            Username = model.Username;
            Fullname = model.Fullname;
            UserCode = model.UserCode;
            Email = model.Email;
            RecordCount = model.RecordCount;
        }


        internal DAL.Models.Admin.UserInGroupModel toDALModel()
        {
            DAL.Models.Admin.UserInGroupModel model = new DAL.Models.Admin.UserInGroupModel
            {
            UserInGroupId = UserInGroupId,
            UserId = UserId,
            GroupId = GroupId,
            Groupname = Groupname,
            Username = Username,
            Fullname=Fullname,
            Email=Email,
            UserCode = UserCode,
            RecordCount = RecordCount
            };
            return model;
        }
    }
}